home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
015
/
oki1.arc
/
OKI.ASM
next >
Wrap
Assembly Source File
|
1985-12-18
|
17KB
|
644 lines
NAME OKI
PAGE 50,130
TITLE OKI.COM RITARI/MACK '85
;
;******************************************************************************
;
;OKI.COM -Setup Utility for Okidata92 printer
; from an idea by Douglas Ritari; PC Tech J., Sep 84, p 79
;
; Joseph MACK
; Dept Chem., UMBC
; 5401 Wilkens Ave
; Catonsville,MD,21228
; (301)-455-2564 (12-5pm)
;
; I hearby release this program into the public domain, Joseph MACK, Oct '85
;
;******************************************************************************
;
;prog constants
cr equ 13
lf equ 10
;
;
MAIN SEGMENT PARA PUBLIC 'CODE'
ORG 100H
START PROC FAR
;
ASSUME CS:MAIN
ASSUME DS:MAIN
ASSUME SS:MAIN
ASSUME ES:MAIN
;
JMP SSTART ;Jump to real start of prog
;
;************************INITIALISE DATA VARIABLES*****************************
;constants initialised at load time, not at execution time
;
SW DB 0 ;Switch for HEX '/' seq.-either '0' or 'FFH'
SIXTEEN DB 16 ;the number '16' used in hex conversion -mul
TESTPR DB 0 ;Switch to test if any output was produced
NUM_DIGITS DB 0 ;Number of hex digits produced-'0' or '1'
FD_OOR DB 0 ;first digit out of range
HEX DB 0 ;hex accumulator
PARM DB 0 ;Move param to here -1 byte at a time
;
;******************************************************************************
; BEGIN PROG- SAVE RETURN ADDRESS FOR DOS
;******************************************************************************
;
SSTART:
PUSH DS ;Save PSP Seg address
MOV AX,0
PUSH AX ;Save return address offset (PSP+0)
;
;***************CHECK PRINTER***************************************************
;
PUSH AX
PUSH DX ;save registers
MOV AH,02 ;read port
MOV DX,0 ;port 00=printer#1
INT 17H ;read status
TEST AH,8H ;bit 3 on?-I/O error
JZ BIT_3_OK
LEA DX,prn_err_bit_3
CALL PRMSG
POP DX
POP AX
RET ;pop registers and exit to DOS
BIT_3_OK:TEST AH,20H ;bit 5 on?-out of paper
JZ BIT_5_OK
LEA DX,prn_err_bit_5
CALL PRMSG
POP DX
POP AX
RET ;exit to DOS
BIT_5_OK:POP DX
POP AX
;
;got here if printer OK
;
;******************MOVE COUNT OF CHARACTERS INTO PARM AREA********************
;
MOV SI,80H ;Source string offset (within PSP)
MOV DI,OFFSET PARM ;dest string offset
CLD ;Set 'forward' string operations
MOVSB ;move # of params entered into 'PARM' variable
DEC DI
;
;*******************SET UP PARM FIELD'S POINTERS*******************************
;
MOV AL,PARM ;Put number of char. in parm into AL register
MOV CX,AX ; " CX
MOV BX,OFFSET PARM ;point to parms base address
CMP CX,0 ;were no parms entered ?
JNE SEARCH ;param found
CALL DEFAULT ;end of search, no parms found-send defaults
RET ;end program, return to DOS,(PSP and offset POPed)
;
;******************************************************************************
; PARMS WERE ENTERED- SEARCH FOR AND PROCESS PARAMETERS
;******************************************************************************
;
SEARCH: MOVSB ;read in parm from prog.seg. prefix
DEC DI
MOV AL,[BX] ;move next parm to input reg
CMP AL,' ' ;blank?
JE SEARCH_END ;ignore
CMP AL,',' ;comma?
JE SEARCH_END ;ignore
;
CMP AL,'a' ;UC/lc?
JL ALPH_HEX ;do not modify this letter if lower than 'a'
AND AL,223 ;reduce by 32, uncaps==>caps
;
ALPH_HEX:CMP SW,0 ;=1 hex sequence on,=0 off
JE SLASH ;expects alph input
CALL HEXON ;expects hex input
JMP SEARCH_END
;
;got here if hex not on
;
SLASH: CMP AL,'/' ;hex sequence begun?
JE SW_ON
CALL ALPHA_ENTRY ;expects alphabetic input
JMP SEARCH_END ;look for next char
;
SW_ON: MOV SW,1 ;turn on hex sequence
SEARCH_END: LOOP SEARCH ;get more input
;
;******************************************************************************
;Get here if no more parms available. Check for unpaired hex digits
;******************************************************************************
;
CMP NUM_DIGITS,0 ;unpaired hexcodes? =0 paired, =1 unpaired?
JE OUT_TEST
PUSH DX
LEA DX,err_msg_6 ;unpaired digits
CALL PRMSG
POP DX
;
CALL DISP_CHAR ;ouput unpaired digit
;
OUT_TEST: CMP TESTPR,1 ;=0 no valid output
JE SUCCESS
CALL DEFAULT
;
SUCCESS: PUSH DX
LEA DX,success_msg
CALL PRMSG
POP DX
;
RET ; to DOS
;
;*************End of prog proc*************************************************
;
START ENDP ;end main
;
;******************************************************************************
;
; ORG 200H
;
PRMSG PROC NEAR
PUSH AX ;int 21h scrambles AX
MOV AH,9 ;print string instruction
INT 21H ;print DX msg
POP AX
RET
PRMSG ENDP
;
;*************Escape routine, send escape code to printer**********************
;
ESCAPE PROC NEAR
PUSH AX ;save potential char to be printed on stack
MOV AL,1BH ;escape char =27 to out reg.
CALL PRINTER
POP AX
CALL PRINTER ;send saved char
RET
ESCAPE ENDP
;
;*************printing s/r- all done from here**********************************
;
;send char in AL to printer
;
PRINTER PROC NEAR
MOV TESTPR,1 ;valid output has been produced
MOV DX,0 ;set register for printer output INT
MOV AH,0 ;"
INT 17H ;call printer driver in BIOS
RET
PRINTER ENDP
;
;*************Edit for valid hex numbers ***************************************
;
HEXON PROC NEAR ;tests for valid hex digit,
;if OK calls HEXMATH, otherwise sends errors
SUB AL,30H ;convert from ASCII to rel numbers (30H=0D)
JC OUT_OF_RANGE ;carry flag set, char<30H=0D, invalid param
CMP AL,9 ;check for digit >9
JBE HEX_OK ;valid number, jump to math routine call
SUB AL,7 ;convert from ASCII to hex A-F
CMP AL,0FH
JA OUT_OF_RANGE ;error if hex>0FH
;
HEX_OK: CALL HEXMATH ;convert input param to hex
RET ;to main
;
;Get here if hex parm not in range 0-0FH
;
OUT_OF_RANGE: CMP NUM_DIGITS,0 ;=0 if first digit
JNE SECOND_DIGIT
INC NUM_DIGITS
MOV FD_OOR,1 ;first digit out of range
CALL HEX_ERR_MSG
RET
;
SECOND_DIGIT:
CALL HEX_ERR_MSG
MOV SW,0 ;reset switches
MOV NUM_DIGITS,0
MOV FD_OOR,0
RET
;
HEXON ENDP
;
;********convert input params to hex numbers*********************************************************************
;
HEXMATH PROC NEAR
CMP NUM_DIGITS,0 ;0= 1st ,1= 2nd number
JNE MATH2 ;jump and process second number
MUL SIXTEEN ;mult 1st number by 16
MOV HEX,AL ;clear & restore result in hex
INC NUM_DIGITS ;1st number processed
RET
;
MATH2: CMP FD_OOR,1 ;0= valid
JE END_MATH
ADD AL,HEX ;second hex number, total the two digits
MOV NUM_DIGITS,0 ;clear digit var for further use
CALL PRINTER ;send hex number in AL to printer
;
END_MATH:MOV FD_OOR,0 ;reset switches
MOV SW,0
RET
;
HEXMATH ENDP
;
;********hex error messages****************************************************
;
HEX_ERR_MSG PROC NEAR
;
PUSH AX ;int 21h scrambles AL
PUSH DX
LEA DX,err_msg_1 ;invalid hex param
CALL PRMSG
POP DX
POP AX
;
CALL DISP_CHAR ;output orig invalid char
;
PUSH DX
LEA DX,err_msg_4 ;parm ignored, execution continued
CALL PRMSG
POP DX
;
RET
;
HEX_ERR_MSG ENDP
;
;******************************************************************************
;
DISP_CHAR PROC NEAR
;
MOV AL,[BX] ;recover orig char
PUSH BX ;save registers before outputting char
PUSH CX
XOR BX,BX ;clear BX, sets page to 0
MOV CX,1 ;1 char to display
MOV AH,0AH ;int fn 10D
INT 10H ;display char at cursor posn
POP CX
POP BX
;
RET
;
DISP_CHAR ENDP
;
;******************************************************************************
;
;*************BUZZER s/r*******************************************************
;sounds buzzer
;
BUZZER PROC NEAR
MOV AL,07 ;buzzer param
CALL PRINTER
RET
BUZZER ENDP
;
;*************DEFAULT S/R*******************************************************
;
;changes TESTPR to 1 through call to PRINTER, so PGMEND detects successfull output
;No params found, set default,
;remove ';' from wanted default instructions
;change default message 'd_msg' when changing defaults
;
;*******************************************************************************
;
; ORG 300H
;
DEFAULT PROC NEAR
;
MOV AL,18H ;cancel
CALL PRINTER
MOV AL,30H ;reset:data processing
CALL ESCAPE ;=pica, 10/"
MOV AL,35H ;logical TOF
CALL ESCAPE
;
;******************************************************************************
;If no param codes entered then give param codes.
;Notify of default execution and type.
;Defaults are set before displaying message.
;If print echoed, will see default font on printer.
;******************************************************************************
;
PUSH DX ;save DX
; LEA DX,prog_name ;prog name
; CALL PRMSG ;print message
LEA DX,d_msg ;default params send to screen
CALL PRMSG
;
LEA DX,inkey_msg ;msg for "inkey to continue"
CALL PRMSG
POP DX
;
MOV AH,0 ;wait for key press
INT 16H ;call keyboard_io at F000:E82E, wait for char
POP AX ;ignore char in AL
;
PUSH DX
LEA DX,p_msg ;param codes available send to screen
CALL PRMSG
POP DX ;recover DX
;
RET
DEFAULT ENDP
;
;******************************************************************************
;PARAMETER DECISION AND ACTION
;******************************************************************************
;
; ORG 400H
;
ALPHA_ENTRY PROC NEAR
;
PARM_C: CMP AL,'C' ;condense?
JNE PARM_E ;17/"
;
MOV AL,1DH
CALL PRINTER ;condensed doesn't need escape
JMP END_PARM
;
PARM_E: CMP AL,'E' ;elite? 12/"
JNE PARM_F
;
MOV AL,1DH ;elite (12 char per inch )
CALL PRINTER
JMP END_PARM
;
PARM_F: CMP AL,'F' ;form feed?
JNE PARM_L
;
MOV AL,0CH ;advance paper to top of form
CALL PRINTER
JMP END_PARM
;
PARM_L: CMP AL,'L' ;line feed
JNE PARM_M
;
MOV AL,0AH
CALL PRINTER
JMP END_PARM
;
PARM_M: CMP AL,'M' ;parm to 'eMphasise'?
JNE PARM_N ;half dot horizontal spacing, double strike
;
MOV AL,54H ;Oki code for eMphasised font
CALL ESCAPE
JMP END_PARM
;
PARM_N: CMP AL,'N' ;set eNhanced mode?
JNE PARM_P ;half dot vertical spacing, double strike
;
MOV AL,48H ;eNlarged
CALL ESCAPE
JMP END_PARM
;
PARM_P: CMP AL,'P' ;pica 10/"
JNE PARM_R
;
MOV AL,1EH
CALL PRINTER
JMP END_PARM
;
PARM_R: CMP AL,'R' ;reinitialise printer?
JNE PARM_S
;
MOV AL,18H ;cancel
CALL PRINTER
MOV AL,30H ;data processing mode
CALL ESCAPE ;pica is normal type size=10 char per inch
MOV AL,35H
CALL ESCAPE ;logical TOF
JMP END_PARM
;
PARM_S: CMP AL,'S' ;.LST and program files, which are wider than 80
JNE PARM_T ;=cm
;
MOV AL,1DH ;condensed
CALL PRINTER
MOV AL,54H ;emphasised
CALL ESCAPE
JMP END_PARM
;
PARM_T: CMP AL,'T' ;Set tabs
JE P_T1
JMP PARM_U ;long jump
;
P_T1: MOV AL,09H ;tab on
CALL ESCAPE
MOV AL,"0"
CALL PRINTER
MOV AL,"5"
CALL PRINTER
MOV AL,","
CALL PRINTER ;tab=05
;
MOV AL,"1"
CALL PRINTER
MOV AL,"0"
CALL PRINTER
MOV AL,","
CALL PRINTER ;tab=10
;
MOV AL,"1"
CALL PRINTER
MOV AL,"5"
CALL PRINTER
MOV AL,","
CALL PRINTER ;tab=15
;
MOV AL,"2"
CALL PRINTER
MOV AL,"0"
CALL PRINTER
MOV AL,","
CALL PRINTER ;20
;
MOV AL,"2"
CALL PRINTER
MOV AL,"5"
CALL PRINTER
MOV AL,","
CALL PRINTER ;25
;
MOV AL,"3"
CALL PRINTER
MOV AL,"0"
CALL PRINTER
MOV AL,","
CALL PRINTER ;30
;
MOV AL,"3"
CALL PRINTER
MOV AL,"5"
CALL PRINTER
MOV AL,","
CALL PRINTER ;35
;
MOV AL,"4"
CALL PRINTER
MOV AL,"0"
CALL PRINTER
MOV AL,","
CALL PRINTER ;40
;
MOV AL,"4"
CALL PRINTER
MOV AL,"5"
CALL PRINTER
MOV AL,","
CALL PRINTER ;45
;
MOV AL,"5"
CALL PRINTER
MOV AL,"0"
CALL PRINTER
MOV AL,","
CALL PRINTER ;50
;
MOV AL,"5"
CALL PRINTER
MOV AL,"5"
CALL PRINTER
MOV AL,","
CALL PRINTER ;55
;
MOV AL,"6"
CALL PRINTER
MOV AL,"0"
CALL PRINTER
MOV AL,","
CALL PRINTER ;60
;
MOV AL,0DH ;<cr>=end of tab entry
CALL PRINTER
JMP END_PARM
;
PARM_U: CMP AL,'U' ;Underline on
JNE PARM_V
;
MOV AL,43H
CALL ESCAPE
JMP END_PARM
;
PARM_V: CMP AL,'V' ;Underline off
JNE PARM_W
;
MOV AL,44H
CALL ESCAPE
JMP END_PARM
;
PARM_W: CMP AL,'W' ;wide, works with CP&E
JNE PARM_X
;
MOV AL,1FH
CALL PRINTER
JMP END_PARM
;
PARM_X: CMP AL,'X' ;teXt mode=Oki correspondance mode
JNE ERROR_3 ;invalid alphabetic parm found, send errors
;
MOV AL,31H
CALL ESCAPE
;
END_PARM: RET ;exit s/r
;
;Invalid alphabetical parameter found
;
ERROR_3: PUSH DX ;write error message
LEA DX,err_msg_3 ;invalid parm msg
CALL PRMSG
POP DX
;
CALL DISP_CHAR
;
ERROR_4: PUSH DX
LEA DX,err_msg_4 ;parm ignored, execution continued
CALL PRMSG
ERROR_5: LEA DX,err_msg_5 ;where to find valid parm list
CALL PRMSG
POP DX
RET ;to main,
;
ALPHA_ENTRY ENDP
;
;******************************************************************************
;Program data
;
; ORG 600H
;
;
p_msg db "Command Format:-OKI [/xx] [a][b] ",cr,lf
db "/xx -heX input (must be paired) ",cr,lf
db " ",cr,lf
db "C -Condensed=17/inch ",cr,lf
db "E -Elite =12/inch *************************** ",cr,lf
db "F -Form feed *Some Command Combinations* ",cr,lf
db "L -Line feed * * ",cr,lf
db "M -eMphasized (hor double) * Type size * ",cr,lf
db "N -eNhanced (ver double) * C E P X * ",cr,lf
db "P -Pica, =10/inch * U + + + + * ",cr,lf
db "R -Reset, logical TOF, Pica * M - + + + * ",cr,lf
db "S -liSt, =c m, .LST files>80 chars * N - + + + * ",cr,lf
db "T -set Tabs; 5,10,15...60 * W + + + + * ",cr,lf
db "U -Underline on * * ",cr,lf
db "V -Underline off *************************** ",cr,lf
db "W -Wide (double) ",cr,lf
db "X -teXt= Okidata92 correspondance quality ",cr,lf
db "/ -Hex on for two digits. ",cr,lf
db " ",cr,lf
db " -Blanks, commas ignored on command line. ",cr,lf
db " UC/lc not differentiated. Hex and alphabetical mixed is OK. ",cr,lf
db " Some commands undo other commands. ",cr,lf,"$"
;
;******************************************************************************
;
success_msg db cr,lf,"OKI.COM Ritari/Mack 1985",cr,lf,"$"
;
prog_name db cr,lf
db "OKI.COM written by Douglas Ritari, 1983",cr,lf
db " modified by Joseph Mack , 1985",cr,lf,lf,"$"
;
d_msg db cr,lf,"These current default codes have been sent to the printer:",,
;
;put command(s) parameters, for current default, into next line, between double quotes
;
db "R"
db cr,lf,lf,"$"
;
inkey_msg db cr,lf,"Press any key to continue. ",cr,lf,"$"
err_msg_1 db cr,lf,"Invalid hex digit found(ie not 0-0FH):$",
err_msg_2 db cr,lf,"No action taken. ",cr,lf,"$"
err_msg_3 db cr,lf,"Invalid alphabetical character:$",
err_msg_4 db cr,lf,"Character ignored, execution continued.$"
err_msg_5 db cr,lf,"Valid parameters available by returning to DOS and typing <OKI>.",cr,lf,"$"
err_msg_6 db cr,lf,"Unpaired hex parameter:$",
err_msg_8 db cr,lf,"Character ignored, execution terminated. ",cr,lf,"$"
got_here_msg db cr,lf,"got here ",cr,lf,"$"
prn_err_bit_3 db cr,lf,"printer I/O error. ",cr,lf,"$"
prn_err_bit_5 db cr,lf,"printer out of paper. ",cr,lf,"$"
;
;******************************************************************************
;
;
MAIN ENDS
END START